/*
 * $Id: XmlView.java,v 1.3 2009/05/11 20:33:27 afaichun Exp $
 * 
 * Copyright (C) 2008 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.onwatch.view;

import java.io.Writer;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.View;

import com.ge.healthcare.autosc.common.ASCLogger;



public class XmlView implements View {

	public String getContentType() {
		return "text/xml";
	}

	public void render(Map model, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// Write the XML document to the response output stream
		setContentType(response);
		String xmlStr = (String)model.get("content");
		Writer writer = response.getWriter();
		ASCLogger.debug(this.getClass(), "render", "Sending xml:\n" + xmlStr);
		writer.write(xmlStr);
		writer.close();
	}
	
	protected void setContentType(HttpServletResponse response) {
		response.setContentType(getContentType());
	}
}
